<?php
set_include_path(realpath('.'));
require('crawler.class.php');
require('wp.php');
require('config.php');
require('phpQuery/phpQuery/phpQuery.php');
function getPosts($id){
	global $linkCrawler;
	$sql = "SELECT * FROM sites WHERE id=" . intval($id);
	$rs = mysql_query($sql, $linkCrawler);
	$links = null;
	if($row = mysql_fetch_array($rs)){
		$url = str_replace(' ', '%20', $row['home_url']);
		$filterUrl = $row['link_filter_type'];
		$urlAdd = $row['link_before'];
		$filterString = base64_decode($row['link_filter_string']);

		$filterDetail = $row['detail_filter_type'];
		$filterContentString = base64_decode($row['filter_string']);
		$removeDom = $row['dom_remove'];
		
		$limitUrl = intval($row['limit']);
		$crawler = new Crawler($url, $limitUrl);
		$links = $crawler->getLinks($filterUrl, $filterString, array(
					'detailType' => $filterDetail,
					'detailString' => $filterContentString,
					'removeDom' => $removeDom,
					'urlAdd' => $urlAdd,
					'demo' => false)
		);
	}
	return $links;
}
